package top.heliming.youyou.item.dao;

import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;
import top.heliming.youyou.item.pojo.Brand;

/**
 * description: //品牌
 *
 * @author: heliming
 * @date:2019/05/27 下午 10:46
 */
public interface BrandMapper extends Mapper<Brand>,SelectByIdListMapper<Brand,Long> {

  /**
   * 新增商品分类和品牌中间表数据
   * @param cid 商品分类id
   * @param bid 品牌id
   * @return
   */
  @Insert("INSERT INTO tb_category_brand (category_id, brand_id) VALUES (#{cid},#{bid})")
  int insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid);


  @Select("SELECT b.* FROM tb_brand b LEFT JOIN tb_category_brand cb ON b.id = cb.brand_id WHERE cb.category_id = #{cid}")
  List<Brand> queryByCategoryId(Long cid);
}
